#include<iostream>
#include<string>
using namespace std;
const int N = 1e6 + 10;
char a[N];
int n;
int main()
{
	cin >> n;
	cin >> a;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 'f' && i + 2 < n) {
			if (a[i + 1] == 'y' && a[i + 2] == 't') {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}